using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper {
	public class RegionMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public RegionMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<region_dto, Region>()
				.ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
				.ForMember(dest => dest.Name, src => src.MapFrom(c => c.name))
				.ForMember(dest => dest.Sort, src => src.MapFrom(c => c.sort))
				.ForMember(dest => dest.ParentId, src => src.MapFrom(c => c.parent_id))
				.ForMember(dest => dest.Depth, src => src.MapFrom(c => c.depth))
				.ForMember(dest => dest.Path, src => src.MapFrom(c => c.path))
				.ForMember(dest => dest.FullName, src => src.MapFrom(c => c.full_name))
				.ForMember(dest => dest.RegionName, src => src.MapFrom(c => c.region_name))
				.ForMember(dest => dest.AreaCode, src => src.MapFrom(c => c.area_code))
				.ForMember(dest => dest.FirstLetter, src => src.MapFrom(c => c.first_letter));
			_cfg.CreateMap<Region, region_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.name, src => src.MapFrom(c => c.Name))
				.ForMember(dest => dest.sort, src => src.MapFrom(c => c.Sort))
				.ForMember(dest => dest.parent_id, src => src.MapFrom(c => c.ParentId))
				.ForMember(dest => dest.depth, src => src.MapFrom(c => c.Depth))
				.ForMember(dest => dest.path, src => src.MapFrom(c => c.Path))
				.ForMember(dest => dest.full_name, src => src.MapFrom(c => c.FullName))
				.ForMember(dest => dest.region_name, src => src.MapFrom(c => c.RegionName))
				.ForMember(dest => dest.area_code, src => src.MapFrom(c => c.AreaCode))
				.ForMember(dest => dest.first_letter, src => src.MapFrom(c => c.FirstLetter));
		}
	}
}
